<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<link href="/static/css/bootstrap.min.css" rel="stylesheet">
	<script src="/static/js/jquery-1.11.1.min.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script src="/static/js/app.js"></script>
	<script src="/static/js/jquery.validate.min.js"></script>
	<script src="/static/js/messages_zh.js"></script>
	<script src="/static/js/additional-methods.js"></script>
</head>
<body>
	<div style="width: 30%;margin: auto;margin-top: 100px;">
		<div class="panel panel-primary">
			<div class="panel-heading">
				<span>登录图书系统</span>
			</div>
			<div class="panel-body">
				<form class="form-horizontal">
					<div class="form-group">
						<label class="control-label col-xs-2">账号</label>
						<div class="col-xs-9">
							<div class="input-group">
                                <span class="input-group-addon">
                                </span>
								<input type="text" class="form-control" name="login">
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-2">密码</label>
						<div class="col-xs-9">
							<div class="input-group">
                                <span class="input-group-addon">
                                </span>
								<input type="password" class="form-control" name="password" >
							</div>
						</div>
					</div>
				</form>
			</div>
			<div class="panel-footer">
				<button type="button" class="btn btn-primary pull-right" id="login">登录</button>
				<button type="button" class="btn btn-success pull-right" id="zhuce">注册</button>
				<div class="clearfix"></div>
			</div>
		</div>
	</div>
<script>
	var body = $('.panel-body');
	var form=$('form');

	form.validate({
		rules:{
			login:{
				required:true
			},
			password:{
				required:true
			}
		},
		messages:{
			login:{
				required:function () {
					var aa=body.showAlert('账号不能为空')
					return aa;
				}
			},
			password: {
				required:function () {
					var bb=body.showAlert('密码不能为空')
					return bb;
				}
			}
		}
	});
	
	$('#login').click(function(){
		if(!form.valid()){
			return;
		}else {
				$.post('',form.serialize(),function(resp){
					if(resp.status){
						location='{:url("Login/index")}'
					}else {
						body.showAlert(resp.message);
					}
				},'json');
		}
	});
	
	$('#zhuce').click(function () {
		location='{:url("Login/zhuce")}'
	})
</script>
</body>
</html>